package main

import "fmt"

type Student struct {
	id   int
	name string
	sex  byte // 字符类型，ASCII
}

func main() {
	s := Student{1, "alfo", 'm'}
	fmt.Println("s =", s) // s = {1 alfo 109}

	test1(s)              // 值传递
	fmt.Println("s =", s) // s = {1 alfo 109}

	test2(&s)             // 引用传递
	fmt.Println("s =", s) // s = {2 alfo 109}
}

func test2(s *Student) {
	//s.id = 2	// 二者完全相同
	(*s).id = 2
}

func test1(s Student) {
	s.id = 2
}
